
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';


/// 下拉刷新 加载更多
class BLSmartRefresher extends StatelessWidget {

  final RefreshController controller;
  final Function() onRefresh;
  final Function() onLoading;
  final bool enablePullDown;
  final bool enablePullUp;
  final ScrollController scrollController;
  final Axis scrollDirection;
  final Widget header;
  final Widget footer;
  final Widget child;

  const BLSmartRefresher({
    Key key,
    @required this.controller,
    this.onRefresh,
    this.onLoading,
    this.enablePullDown = true,
    this.enablePullUp = true,
    this.scrollController,
    this.scrollDirection,
    this.header = const ClassicHeader(), // 默认是 Material 风格
    this.footer = const ClassicFooter(), // 经典的加载更多
    this.child
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SmartRefresher(
      controller: this.controller,
      onRefresh: this.onRefresh,
      onLoading: this.onLoading,
      enablePullDown: this.enablePullDown,
      enablePullUp: this.enablePullUp,
      scrollController: this.scrollController,
      scrollDirection: this.scrollDirection,
      header: this.header,
      footer: this.footer,
      child: this.child,
    );
  }
}
